home *** CD-ROM | disk | FTP | other *** search
/ Celestin Apprentice 2 / Apprentice-Release2.iso / Source Code / AppleScript / Additions / Wild 1.0.1 / Wild Read Me < prev    next >
Encoding:
Text File  |  1994-01-24  |  9.5 KB  |  210 lines  |  [ttro/ttxt]

  1.  
  2.  
  3.  
  4.  
  5. “Wild” is an AppleScript™ addition which expands wildcarded file and folder names.
  6.  
  7.  
  8.  
  9.  
  10. Open the ‘Extensions’ folder inside the ‘System Folder’ on your startup disk. There you should find a folder named ‘Scripting Additions’. Just copy “Wild” into the ‘Scripting Additions’ folder and you will be all set.
  11.  
  12.  
  13.  
  14.  
  15. If you open the “Wild” dictionary from within the Script Editor, this is what you see:
  16.  
  17.  
  18.  
  19.  
  20.  
  21.  
  22.  
  23.  
  24.  
  25.  
  26.  
  27.  
  28.  
  29.  
  30.  
  31.  
  32.  
  33. It looks more complicated than it actually is. Ignore for the moment the optional parameters and remember that AppleScript™ automatically converts single items to one-element lists. What you are left with is a simple command like this:
  34.  
  35.           set resultingList to expand wildcards "bla*"
  36.  
  37. The variable ‘resultingList’ will then contain the list of all files and folders in your startup volume's top directory whose names begin with ‘bla’. Another example:
  38.  
  39.           set resultL to expand wildcards "a floppy:?????*"
  40.  
  41. sets the variable resultL to the list of all files and folders with a name of at least five characters which are on the volume named ‘a floppy’.
  42.  
  43. To be precise, ‘expand wildcards’ returns the full path of the items that it selects, not only their name. A command like:
  44.  
  45.          set res to expand wildcards {"vol2:fold:file*", "vol3:file*"}
  46.  
  47. would return a list similar to:
  48.  
  49.           {"vol2:fold:file1", "vol2:fold:file2", "vol2:fold:file3", "vol3:file1", "vol3file2"}
  50.  
  51. Notice that if you don't choose your input list carefully, you might end up with multiple references to the same file. For example:
  52.  
  53.           {"vol3:*i*", "vol3:*1*}
  54.  
  55. could produce something like:
  56.  
  57.           {"vol3:file1",  "vol3:file2",  "vol3:file1"}
  58.  
  59. Before we examine the optional parameters one by one, remember that AppleScript groups all boolean parameters at the end of a command. Also, if you repeat a parameter, AppleScript only "passes on" the last one.
  60.  
  61.  
  62. The ‘long wildcard’ is a character which can match character sequences of any length. By default, this character is an asterisk ('*'). A single long wildcard matches all possible filenames and it is never necessary to build up sequences of long wildcards. That is, "a**b***" is totally equivalent to "a*b*". A long wildcard also matches an "empty" sequence of characters. So, for example, "*x*" matches all filenames which begin or terminate with 'x'.
  63.  
  64. The parameter ‘long wildcard’ changes the long wildcard to any character. This is useful when you want to search for files which contain a '*' in their name. Although this parameter accepts a string, only the first character is actually used.
  65.  
  66.  
  67. The ‘short wildcard’ is a character which matches exactly one character. By default, this character is a question mark ('?'). When associated with a long wildcard, the number of consecutive short wildcards determines the "minimum" length of the long wildcard. For example, "p??*" matches all filenames which start with the letter 'p' and contain at least 3 characters. Note that sequences of wildcards like "?*?", "*??", and "**?**?**" are perfectly identical. Also note that a short wildcard REQUIRES a character to be there. So, for example, "abc?" does NOT match "abc".
  68.  
  69. The parameter ‘short wildcard’ changes the short wildcard to any character. This is useful when you want to search for files which contain a '?' in their name. Although this parameter accepts a string, only the first character is actually used.
  70.  
  71.  
  72. Tells “Wild” to ignore the files when scanning the contents of a directory. That is, add “without files” to your “expand wildcards” command if you are only interested in folders. Note that  “without files and folders” does not make sense, because the output list would always be empty!
  73.  
  74.  
  75. Tells “Wild” to ignore the folders when scanning the contents of a directory. That is, add “without folders” to your “expand wildcards” command if you are only interested in files. Note that  “without folders and files” does not make sense, because the output list would always be empty!
  76.  
  77.  
  78. Tells “expand wildcards” to list files created with a certain application and ignore the others. For example, “creator "ttxt"” would only list files created with TeachText™. This parameter has no effect on folders. Although this parameter accepts a string, only the first 4 characters are actually used. If the string contains less than 4 characters, it is extended to 4 by appending NULL characters (ASCII 0). This parameter accepts short wilcards to help you identify files of which you do not remember the full creator string.
  79.  
  80.  
  81. Tells “expand wildcards” to list files of a certain type and ignore the others. For example, “file type "TEXT"” would only list text files. This parameter has no effect on folders. Although this parameter accepts a string, only the first 4 characters are actually used. If the string contains less than 4 characters, it is extended to 4 by appending NULL characters (ASCII 0). This parameter accepts short wilcards to help you identify files of which you do not remember the full file type.
  82.  
  83.  
  84. The Finder™ does not distinguish between upper and lower cases. Still, in some cases it might be useful to do so. “expand wildcard with case sensitive” matches upper and lower cases when scanning the contents of a directory. For example,
  85.  
  86.           set outList to expand wildcards "F*" with case sensitive
  87.  
  88. would find "File1", "File2", and "Folder3" but not "file4" or "folder5".
  89.  
  90.  
  91. “expand wildcards” uses the “only-string” to apply a second wildcard filtering before "passing" a name. For example,
  92.  
  93.           set outL to expand wildcards "myFold:*a*" only "*b*" without folders
  94.  
  95. returns all the filenames which contain an 'a' AND a 'b' in any position. The command
  96.  
  97.           set outL to expand wildcards {"myFold:*a*", "myFold:*b*"} without folders
  98.  
  99. would return all the filenames which contain EITHER an 'a' OR a 'b' in any position. Moreover, filenames like "bla", "abcd", or "this is a file" would appear twice in the output list.
  100.  
  101. Note that the “only-string” never contains a path, because it is applied to file and folder names which have already been identified by the first wildcarding.
  102.  
  103. A very good way of using “only” is to apply "cascading" wildcard selections. For example:
  104.  
  105.           set outL to expand wildcards "a*z" only "*h*"
  106.           set buffL to expand wildcards outL only "???g*"
  107.           set outL to expand wildcards buffL only "?????*"
  108.  
  109. lists in 'outL' all file and folder names which:
  110.     begin with 'a',
  111.     end with 'z',
  112.     contain an 'h' in any position,
  113.     contain a 'g' in fourth position, and
  114.     are at least 5 characters long.
  115.  
  116.  
  117. Normally, you will use “expand wildcards” with parameters typed within the script as explained above. The parameter “dialog” let's you enter all optional parameters from the keyboard. Also, “dialog” accepts your licence number for “Wild”. When you add “with dialog” to the “expand wildcards” command, you get a dialog box like this:
  118.  
  119.  
  120.  
  121.  
  122.  
  123.  
  124.  
  125.  
  126.  
  127.  
  128.  
  129.  
  130.  
  131.  
  132.  
  133.  
  134.  
  135.  
  136.  
  137.  
  138.  
  139.  
  140. The contents of the various fields will show the values that you passed to the “expand wildcards” command in your script.
  141.  
  142.  
  143.  
  144. This is an editable text field which lets you type in the string for the “only” parameter.
  145.  
  146.  
  147.  
  148.  
  149.  
  150.  
  151.  
  152.  
  153.  
  154.  
  155.  
  156.  
  157.  
  158.  
  159. These fields let you set the remaining optional parameters. You will notice that the dialog automatically truncates the strings if they exceed their maximum length.
  160.  
  161.  
  162.  
  163.  
  164.  
  165. “cancel” aborts “expand wildcards” and interrupts the script.
  166.  
  167.  
  168.  
  169. “default” resets all the fields to their defaults (look at the full dialog to find out what they are).
  170.  
  171.  
  172.  
  173. “restore” sets all the fields to the values that you passed to the “expand wildcards” command in your script. That is, it restores them to what they were when the dialog was first displayed.
  174.  
  175.  
  176.  
  177. “OK” directs “expand wildcards” to go ahead and process the input list with the optional parameters as currently displayed.
  178.  
  179.  
  180.  
  181.  
  182. “Wild” is available for you at no charge. Feel free to pass it on to friends and colleagues. Nevertheless, you are not allowed to sell “Wild” or distribute it for commercial purposes or as part of any shareware or commercial package.
  183.  
  184. Provided you are a registered user of MacDOS™ (the Rainbow Hill's product which implements a command line interface for Macintosh), we will give you free support for “Wild”.
  185.  
  186. The best way of getting in touch with Rainbow Hill is via E-mail:
  187.  
  188.     from the Internet:    giulio@DIALix.oz.au
  189.     from CompuServe:    >INTERNET:giulio@DIALix.oz.au
  190.     from AppleLink:       giulio@DIALix.oz.au@internet#
  191.     from GEnie:              giulio@DIALix.oz.au@inet#
  192.  
  193. or send a fax to:  +61-9-447-8418
  194.  
  195. or mail to:      Rainbow Hill Pty Ltd
  196.                       Att.  Giulio Zambon
  197.                       25 Urawa Road
  198.                       Duncraig   WA   6023
  199.                       Australia
  200.  
  201. If you don't have MacDOS™, you can get support after paying a modest one-off fee of A$10: send your name and address[es] via mail, specify the release of “Wild” that you are using, and include a A$10 bill (be aware that in your country it might be against the law to send cash via mail).
  202.  
  203. Alternatively, send a bank cheque or a traveller cheque. We can only accept personal cheques if they are in Australian Dollars.
  204.  
  205. If you are not in Australia and don't like to go to the bank to buy Australian Dollars, convert A$10 to your local currency, round it up to the closest amount payable with banknotes (NO COINS, PLEASE) and send that. Some figures valid at the time of writing are: US$10, DEM20, ¥1000, LIT10000.
  206.  
  207. Naturally, you can always report a bug without having MacDOS™ or paying a support fee!  We would also like to hear from you any comment or suggestion concerning “Wild”.
  208.  
  209. ____________________________________________________________________
  210. Copyright © 1994 by Rainbow Hill Pty Ltd. All rights reserved.